import threading
import queue

q = queue.Queue()

def worker():
    """如何等待排队的任务被完成的示例"""
    while True:
        items = q.get()
        print(f'Working on {items}')
        print(f'Finished {items}')
        q.task_done()


threading.Thread(target=worker).start()

for item in range(100):
    q.put(item)

q.join()
print('all work completed')
